//
//  DicussMessageTable.m
//  OperationPro
//
//  Created by yaxue wang on 16/11/10.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "DicussMessageTable.h"
#import "DicussMessageCell.h"
#import "DicussMessageModel.h"
@implementation DicussMessageTable


- (void)initView{
    [super initView];
    [self setShowNoDataNotice:@"暂无内容"];
    self.backgroundColor =BackColor;
    self.separatorStyle=UITableViewCellSeparatorStyleNone;
    self.showsVerticalScrollIndicator =NO;
    [self registerCell:[DicussMessageCell class] withModel:[DicussMessageModel class]];
    [self setDataWithUrl:@"message_showDiscussionNotify" andParam:nil];
    [self setTableActionType:CTableActionType_Both];
    [self loadData];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.mainData.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return  130;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *cellID = [NSString stringWithFormat:@"Cell_%@", NSStringFromClass([DicussMessageModel class])];
    DicussMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[DicussMessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.selectionStyle=UITableViewCellSelectionStyleNone;

    DicussMessageModel *model = [self.mainData objectAtIndex:indexPath.row];
    [cell setModel:model];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    DicussMessageModel *model = [self.mainData objectAtIndex:indexPath.row];
    NSString *str =model.D_content;
    NSArray *array = [str componentsSeparatedByString:@","];
    NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];

    if (array.count==0) {
        [dic setObject:[array objectAtIndex:0] forKey:@"uuid"];
        [dic setObject:@"" forKey:@"warningUuid"];
    }else
    {
        [dic setObject:[array objectAtIndex:0] forKey:@"uuid"];
        [dic setObject:[array objectAtIndex:1]forKey:@"warningUuid"];

    }
   
    if (self.CCellSelect) {
        self.CCellSelect(dic);
      
    }
   
}


@end
